exports.mongoose = () => {
  const mongoose = require("mongoose");

  mongoose.connect(
    "mongodb://localhost:27017/koa",
    {
      useNewUrlParser: true,
      useUnifiedTopology: true,
    },
    (err, data) => {}
  );

  const Schema = new mongoose.Schema({
    name: { type: "String" },
    age: { type: "Number", default: 100 },
  });

  const demo = mongoose.model("newDemo", Schema);

  //    demo.create({ name: "zs" }, { name: "bb" }).then((res) => {
  //     console.log(res);
  //   });

  //   demo.create({ name: "ls" }).then((res) => {
  //     console.log(res);
  //   });

  //   demo.find({ name: "zs" }).then((res) => {
  //     console.log(res);
  //   });

  //   demo.find().then((res) => {
  //     console.log(res);
  //   });

  //   demo.deleteOne().then((res) => {
  //     console.log(res);
  //   });

  //   demo.findByIdAndDelete({ _id: "612d73331d192a1120b0162f" }).then((res) => {
  //     console.log(res);
  //   });

  //   demo.deleteMany({ name: "bb" }).then((res) => {
  //     console.log(res);
  //   });

  //   demo.updateOne({ name: "牛牛" }, { name: "zs" }).then((res) => {
  //     console.log(res);
  //   });
};
